package cn.lcc.ymcc.web.controller;



import cn.lcc.ymcc.dto.SendSmsParamDto;
import cn.lcc.ymcc.result.JSONResult;
import cn.lcc.ymcc.service.ISendSmsCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private ISendSmsCodeService sendSmsCodeService;
    /*
        imageCode
        imageCodeKey
        mobile
     */
    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid SendSmsParamDto sendSmsParamDto){
        sendSmsCodeService.sendCode(sendSmsParamDto);
        return JSONResult.success();
    }
    /**
     * 接口：图形验证码
     * @param key
     * @return
     */
    @GetMapping("/imageCode/{key}")
    public String getImageCode(@PathVariable("key")@Valid String key){
        return sendSmsCodeService.getImageCodeKey(key);

    }
}
